<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>JS02</title>
    </head>
    <body>

        <button>按钮</button>

        <script>
            //传统方式
            var obj1 = new Object();
            obj1.a=90;
            obj1.b="abc";
            obj1.show=function(){
                console.log(this.a+","+this.b);
            };

            obj1.show();


            obj1['id']='001';
            obj1['info']=function(){
                console.log(this['a']+","+this.id);
            }

            console.log(obj1['b']+","+obj1.id)

            obj1.info();
            obj1['info']();

            //json方式
            var ob = {
                "stuId":'001',
                "stuName":"张三",
                "stuScore":98,
                "info":function(){
                    alert(this.stuId+","+this["stuName"]+","+this.stuScore);
                }
            };

            ob.info();

            var arr = [2,3,4];

            document.querySelector('button').onclick=function(){

                alert(this.innerHTML);

                return false;
            }

        </script>



    </body>


</html>